-
Notifications
You must be signed in to change notification settings - Fork 305
Highlight mentions in MessageComposer (Compose) #5984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Highlight mentions in MessageComposer (Compose) #5984
Conversation
SDK Size Comparison 📏
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds mention highlighting support to the MessageComposer input field in the Compose UI. The feature is disabled by default for backwards compatibility and includes support for custom mentions (visual only, not submitted to backend).
Key changes:
- Introduces
MentionandMentionTypeclasses for building custom mentions - Adds
MentionStyleFactoryinterface for customizing mention appearance - Separates text formatting logic into
buildAnnotatedMessageText(for message bubbles) andbuildAnnotatedInputText(for input fields)
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| Mention.kt | Defines MentionType and Mention interface with default Mention.User implementation |
| MessageComposerController.kt | Updates mention selection logic to support both user and custom mentions |
| MessageComposerState.kt | Adds selectedMentions field to track mentions in composer state |
| TextUtils.kt | Splits annotation logic into separate functions for message bubbles and input fields |
| MessageComposerTheme.kt | Adds MentionStyleFactory interface and integrates it into ComposerInputFieldTheme |
| MessageInput.kt | Implements visual transformation to apply mention styling in the composer |
| InputField.kt | Extracts default visual transformation logic and adds customization support |
| PollOptionInput.kt | Updates to use buildAnnotatedInputText instead of buildAnnotatedMessageText |
| MessageComposerViewModel.kt | Adds overload for selectMention accepting Mention parameter |
| CustomMentionStyleFactory.kt | Sample implementation showing how to customize mention colors |
| MessagesActivity.kt | Demonstrates integration of custom mention styling in the sample app |
| Test files | Adds comprehensive tests for mention functionality |
| API files | Documents public API changes for mention support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| val start = text.indexOf(mention.display) | ||
| val end = start + mention.display.length | ||
| if (start < 0) return@forEach |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using indexOf will only find the first occurrence of the mention display text. If the same mention appears multiple times in the text, only the first occurrence will be styled. Consider finding all occurrences or using the mention's position information if available.
| } | ||
|
|
||
| /** | ||
| * |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line at line 114 before the KDoc content. Remove the blank line after the opening '/**' to follow KDoc formatting conventions.
| * |
| addStyle(style, start - 1, end) // -1 to include the @ symbol | ||
| addStringAnnotation(AnnotationTagMention, mention.display, start - 1, end) // -1 to include the @ symbol |
Copilot
AI
Oct 28, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code assumes the '@' symbol is always immediately before the mention display text. This assumption may not hold if the text is modified or if mentions are inserted in different contexts. Consider storing the actual position of mentions or validating that the character at start - 1 is indeed '@'.
|


🎯 Goal
MessageComposerinput field. For backwards compatibility, this is disabled by default.Usage
To customise the appearance of the mentions in the
MessageComposer:To select a custom mention:
🛠 Implementation details
MentionTypeandMentionclasses -> used to build custom mentions. Also defines the defaultMessageComposerViewModel.selectMention(mention: Mention)to allow selecting custom mentionsMentionStyleFactoryto allow customisation of the appearance in theMessageComposerbuildAnnotatedMessageTextinto:buildAnnotatedMessageTextandbuildAnnotatedInputText- one for formatting message text (in bubble), and one for formatting input texts.🎨 UI Changes
Sample only
🧪 Testing
Default user mentions in sample:
@in composerCustom mentions:
@in composer#channelmention optionProvide the patch summary here